#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int ret = 0, in = 10000, out = -1;
        for (auto i : prices)
        {
            if (in > i) in = i, out = -1;
            else if (i > out) out = i, ret = max(out - in, ret);
        }
        return ret;
    }
};